package com.yunchang.springboot.utils.mwsutils;

import com.yunchang.springboot.mapper.mwsutils.CwfzFinancialSubjectsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class GetSubjectUtil {

    /**
     * 获取借贷的科目
     */
    private static CwfzFinancialSubjectsMapper cwfzFinancialSubjectsMapper;

    @Autowired
    public void setCwfzFinancialSubjectsMapper(CwfzFinancialSubjectsMapper cwfzFinancialSubjectsMapper){
        GetSubjectUtil.cwfzFinancialSubjectsMapper = cwfzFinancialSubjectsMapper;
    }

    /**
     * 根据type获取借方科目
     * @param type
     * @return
     */
    public static String getDebitSubjectId(String type){
        if(StringUtils.isEmpty(type)){
            return "";
        }
        log.info(type);
        return cwfzFinancialSubjectsMapper.selectDebitSubjectIdByType(type);
    }


    /**
     * 根据type获取贷方科目
     * @param type
     * @return
     */
    public static String getCreditSubjectId(String type){
        if(StringUtils.isEmpty(type)){
            return "";
        }
        return cwfzFinancialSubjectsMapper.selectCreditSubjectIdByType(type);
    }
}
